package com.qianfeng.smartdevices.pojo;


import org.springframework.util.ObjectUtils;

import java.util.Objects;

public class Categories implements CheckNull {

  private Long id;
  private String categoryname;
  private String txcommand;
  private String rxcommand;
  private String commandname;
  private Long status;

  @Override
  public boolean isNull(CheckStatus status) {
    switch (status) {
      case ADD:
        return ObjectUtils.isEmpty(categoryname);
      case UPDATE:
        return  (id == null || id <= 0) || (ObjectUtils.isEmpty(categoryname)&&ObjectUtils.isEmpty(this.status)&&ObjectUtils.isEmpty(commandname)&&ObjectUtils.isEmpty(rxcommand)&&ObjectUtils.isEmpty(txcommand));
    }
    return false;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    Categories that = (Categories) o;
    return Objects.equals(id, that.id) && Objects.equals(categoryname, that.categoryname) && Objects.equals(txcommand, that.txcommand) && Objects.equals(rxcommand, that.rxcommand) && Objects.equals(commandname, that.commandname) && Objects.equals(status, that.status);
  }



  public Long getId() {
    return id;
  }

  public void setId(Long id) {
    this.id = id;
  }

  public String getCategoryname() {
    return categoryname;
  }

  public void setCategoryname(String categoryname) {
    this.categoryname = categoryname;
  }


  public String getTxcommand() {
    return txcommand;
  }

  public void setTxcommand(String txcommand) {
    this.txcommand = txcommand;
  }


  public String getRxcommand() {
    return rxcommand;
  }

  public void setRxcommand(String rxcommand) {
    this.rxcommand = rxcommand;
  }


  public String getCommandname() {
    return commandname;
  }

  public void setCommandname(String commandname) {
    this.commandname = commandname;
  }


  public Long getStatus() {
    return status;
  }

  public void setStatus(Long status) {
    this.status = status;
  }
}
